package com.wans.guli.common.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CharacterEncodingFilter;

//@Configuration
public class CharsetConfig {

//    @Bean
    public FilterRegistrationBean<CharacterEncodingFilter> charsetFilter() {
        FilterRegistrationBean<CharacterEncodingFilter> registration = new FilterRegistrationBean<>();
        CharacterEncodingFilter filter = new CharacterEncodingFilter();
        filter.setEncoding("UTF-8");
        filter.setForceEncoding(true); // 强制请求和响应都使用UTF-8
        registration.setFilter(filter);
        registration.addUrlPatterns("/*");
        return registration;
    }
}